#include "Enemy.h"
#include "Level.h"

Enemy::Enemy()
{
   Create("../../resource/sphere.bmp",CVector(64,64));
    giveAtry.Init((rand()%5000)+1000);
    AddAnimationRange(30,true,0,31);
    SetCurrentAnimation(0);
}

Enemy::~Enemy()
{

}

void Enemy::Execute()
{
    HandleLife();
    if(lifePoints > 0){
        if(giveAtry.Ended()){
            if(bCanShot)
                Shoting();
            giveAtry.Restart();
        }
        giveAtry.Update();
    }
}

void Enemy::Shoting()
{
    Shot* shot = new Shot(this,2);
    shot->Position = CVector(Position.fx+(pr_Image->FrameSize.fx/2.8f),Position.fy-(pr_Image->FrameSize.fy/-2.8f));
    CCore::getInstance()->GetCurrentScene<Level>()->layerScreen->AddSprite(shot);
}
